package com.wust.ad;

import java.util.ArrayList;
import java.util.HashMap;

import com.wust.R;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class adActivity extends ListActivity{
	private ListView listview=null;
	private ArrayList<HashMap<String, Object>> listItems;
	private TextView loveangel_title=null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.ad);
		listview=getListView();
		listview.setAdapter(buildAdapter());
	}
	private  SimpleAdapter buildAdapter(){
		listItems = new ArrayList<HashMap<String, Object>>();    	
        HashMap<String, Object> map1 = new HashMap<String, Object>();           	        
        map1.put("ad_img", R.drawable.ad1);     //文字   
        listItems.add(map1); 
        HashMap<String, Object> map2 = new HashMap<String, Object>();                    
        map2.put("ad_img", R.drawable.ad2);     //文字 
        listItems.add(map2);
        HashMap<String, Object> map3 = new HashMap<String, Object>();                    
        map3.put("ad_img", R.drawable.ad3);     //文字 
        listItems.add(map3);
        HashMap<String, Object> map4 = new HashMap<String, Object>();                    
        map4.put("ad_img", R.drawable.ad4);     //文字 
        listItems.add(map4);
        HashMap<String, Object> map5 = new HashMap<String, Object>();                    
        map5.put("ad_img", R.drawable.ad5);     //文字 
        listItems.add(map5);
           
        //生成适配器的Item和动态数组对应的元素       
        SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItems,//数据源        
            R.layout.ad_item,//ListItem的XML布局实现       
            //动态数组与ImageItem对应的子项               
            new String[] {"ad_img"},        
            //ImageItem的XML文件里面的一个ImageView,两个TextView ID       
            new int[] {R.id.ad_img}       
        ); 
        return listItemAdapter;
	}
	private void buildList(){
		listview.setAdapter(buildAdapter());
	}
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		
		super.onListItemClick(l, v, position, id);
		//要跳转的Activity  
		
			
	}
}
